home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 2814 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.9 KB

  1. Path: docnet.infolink.co.za!julian
  2. From: julian@docnet.infolink.co.za (Julian van Tubbergh)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: GoTo equivalent in C ??
  5. Date: 24 Jan 1996 05:31:57 GMT
  6. Organization: No organisation supplied
  7. Message-ID: <4e4g8d$qbk@hermes.is.co.za>
  8. References: <4d67vm$e5h@masala.cc.uh.edu> <4d8sa6$mqc@news.iag.net> <4de4ae$h6a@masala.cc.uh.edu> <DLE24I.Jur@thinkage.on.ca>
  9. NNTP-Posting-Host: docnet.infolink.co.za
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. Alan Bowler (atbowler@thinkage.on.ca) wrote:
  13. : In article <4de4ae$h6a@masala.cc.uh.edu> sukku@menudo.uh.edu (sukumar) writes:
  14. : >
  15. : >What does everyone do?? I have always been tempted to use goto especially in 
  16. : >functions involving a lot of computation and error checking.
  17. : >I have heard people say "People who don't know how to code use GOTO". I was
  18. : >curious to know how guys that say this solve the above problem.
  19. : >
  20. : The people who make such blanket statements about goto's are just
  21. : wrong.  Used judiciously, goto's are a valuable part of a programmer's
  22. : tool kit.  It is true that any goto/label pair can be replaced with
  23. : some set of if/while/flag-variables but applying this approach
  24. : mechanically results in even worse spaghetti.  Back when I was first
  25. : getting into the buisiness (Before the famous "Goto's considered
  26. : harmful" letter), a shop I worked at had a style prohibition against
  27. : switch variables.  
  28.  
  29. : One common case where goto's are often the best choice is the
  30. : "ooops, something failed, goto common cleanup code" situation.
  31.  
  32. This is a bit off-topic, but this is exactly the kind of problem that 
  33. exception handling (found in languages like C++ and Delphi) so very 
  34. elegantly solves.
  35.  
  36. Julian.
  37.  
  38. ------------------------------------------------------------------------
  39. Julian van Tubbergh
  40. IT systems specialist, Promat Colleges, South Africa.
  41. ------------------------------------------------------------------------
  42.